/*
 * CTDR_Field.cpp
 *
 *  Created on: 1 déc. 2010
 *      Author: mbenoit
 */
#include "CTDR_Field.h"
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <string>
using namespace std;

//ClassImp(CTDR_Field)

//////////////////////////////////////////////////////////////////////////
// This class represent the CTDR_Field in the CZT detector. CTDR_Field 	//
// data are read from a ROOT  file and stored in a TTree.This class pass//
// to the simulation the value of the CTDR_Field at a position x,y,z,	//
// on demand. This class is similar to the class Detecteur.		//
//////////////////////////////////////////////////////////////////////////


//______________________________________________________________________________
CTDR_Field::CTDR_Field(double LX,double LY, double LZ)
{
// Constructor for the CTDR_Field
// We retrieve 3 TTree from a file. These data tree contain data of the CTDR_Field inside a logical pixel of
// our detector. The data are obtained from a finite-emelent analysis software, COMSOL multiphysics, and
// we retreive an array of 100*100*100 for nodes inside the model at constant distance. Each data point
// is assigned a unique ID calculated from its position. It allow us to get the memory adress of a CTDR_Field value
// by calculating the ID associated to the position where we need the value. We then retreive the CTDR_Field
// value from the tree using this unique ID pointing to its adress in the tree's memory
// The data trees are created one time , prior to simulation, using Treereader.c ROOT script .
// This allow to modify the script to use CTDR_Field Data from various sources without touching this code.
// The Storage of the data in .root files allow to get in memory large amount of data, compressed with
// an efficient method that allow a fast acces to data in the tree. S
// parameters: (reference to the ROOT file, number of division in X (100), in Y, in Z, size of the model
// in X,Y,Z)

                   this->LX=LX;
                   this->LY=LY;
                   this->LZ=LZ;

   cout << TString::Format("[CTDR_Field] Electric field Single cell dimension (Lx,Ly,Lz)=(%4.4f,%4.4f,%4.4f)",LX,LY,LZ) << endl;

//______________________________________________________________________________

};
                   double CTDR_Field::GetEx()
{
//Data access function for the CTDR_Field components
     return Ex;
};

//______________________________________________________________________________
double CTDR_Field::GetEy()
{
//Data access function for the CTDR_Field components
       return Ey;
};

//______________________________________________________________________________
double CTDR_Field::GetEz()
{
//Data access function for the CTDR_Field components
       return Ez;
};



void CTDR_Field::SetEx(double Ex){this->Ex=Ex;};
void CTDR_Field::SetEy(double Ey){this->Ey=Ey;};
void CTDR_Field::SetEz(double Ez){this->Ez=Ez;};

//______________________________________________________________________________
double CTDR_Field::GetLz(){
//Access method for the Model depth in z
       return LZ;
       };






